package com.x.erp.dao;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.x.erp.model.Color;
import com.x.framework.dao.BaseDao;

@Repository
public class ColorDao extends BaseDao{
	
	/**
	 * 查询颜色
	 * @param rotation
	 * @return
	 */
	private final static String selectColorListSql = "SELECT T1.* FROM BASE_COLOR T1 WHERE 1=1 ";
    public List<Color> selectColorList(Color color) throws Exception {
        StringBuilder sql = new StringBuilder(selectColorListSql);
        List<Object> params = new ArrayList<Object>();
        if (this.isNotNull(color.getColorId())) {
            sql.append("AND T1.COLOR_ID = ? ");
            params.add(color.getColorId());
        }
        if (this.isString(color.getColorName())) {
            sql.append("AND T1.COLOR_NAME = ? ");
            params.add(color.getColorName());
        }
        if (this.isString(color.getColorCode())) {
            sql.append("AND T1.COLOR_CODE = ? ");
            params.add(color.getColorCode());
        }
        if (color.getColorIn() != null) {
            sql.append("AND T1.COLOR_IN = ? ");
            params.add(color.getColorIn());
        }
        if (color.getColorOut() != null) {
            sql.append("AND T1.COLOR_OUT = ? ");
            params.add(color.getColorOut());
        }
        return this.queryForList(sql.toString(), Color.class, params, color);
    }

}
